<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
   xmlns:f="http://xmlns.jcp.org/jsf/core"
   xmlns:h="http://xmlns.jcp.org/jsf/html"
   xmlns:p="http://primefaces.org/ui"
   xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
   template="/WEB-INF/templates/default.xhtml">
   
   	<f:metadata>   		
	   	<f:viewParam name="serviceSupplierId" value="#{serviceSupplierHome.id}"></f:viewParam>
	   	<f:event listener="#{serviceSupplierHome.initConversation()}" type="preRenderView"></f:event>
   	</f:metadata>
    <ui:define name="head">
    	<style type="text/css">
   			.column1 {
		     width: 10%;
			}
			
			.column2 {
			     width: 90%;
			}
			
			.top-alignment {
			     vertical-align: top;
			}
    	</style>
    
    </ui:define>
   	<ui:define name="content">
   
		<h:form id="editForm">         
			<p:panel id="panel" header="审核中介资质信息" style="margin-bottom:10px;">
		       <p:messages id="messages" closable="true"><p:autoUpdate/></p:messages>
		        
		        <h:panelGrid columns="2" cellpadding="5" columnClasses="label, value">
					<p:outputLabel value="公司名称" />		
					<h:outputText value="#{certHome.instance.serviceSupplier.cnname}" />		
											   
					<p:outputLabel value="单位性质或组织形式" />				
					<h:outputText id="companyType" 
								  value="#{certHome.instance.serviceSupplier.companyType}"/>
					
					<p:outputLabel value="统一社会信用代码" />
					<h:outputText id="creditCode" 
							   value="#{certHome.instance.serviceSupplier.creditCode}" />
					
					<p:outputLabel value="注册资金(万元)" />				
					<h:outputText id="registeredFund" 
							  value="#{certHome.instance.serviceSupplier.registeredFund}" />
					
					<p:outputLabel value="注册登记机关" />				
					<h:outputText id="registrationAuthority" 
							  value="#{certHome.instance.serviceSupplier.registrationAuthority}" />
					
					<p:outputLabel value="注册登记号" />				
					<h:outputText id="registrationNo" 
							  value="#{certHome.instance.serviceSupplier.registrationNo}" />
					
					<p:outputLabel value="成立时间" />		
					<h:outputText  id="regtime" 
								value="#{certHome.instance.serviceSupplier.regtime}">
						<f:convertDateTime pattern="yyyy-MM-dd"/>
					</h:outputText>
					
					<p:outputPanel>
						<p:outputLabel value="营业执照" />
					</p:outputPanel>
					<div id="imgsPreview" >
						<img  data-original="#{attachmentUtils.getFullPath(certHome.instance.serviceSupplier.businessLicenseImages[0])}" src="#{attachmentUtils.getFullPath(certHome.instance.serviceSupplier.businessLicenseImages[0])}"  width="240"/>
					</div>
					
					<p:outputLabel value="办公地址" />				
					<h:outputText id="address" 
							  value="#{certHome.instance.serviceSupplier.address}" />
					
					<p:outputLabel value="法定代表人" />				
					<h:outputText id="legalPerson" 
							  value="#{certHome.instance.serviceSupplier.legalPerson}" />
					
					<p:outputLabel value="法定代表人联系电话" />				
					<h:outputText id="legalPersonPhoneNumber" 
							  value="#{certHome.instance.serviceSupplier.legalPersonPhoneNumber}" />
					
					<p:outputLabel value="第一联系人" />				
					<h:outputText id="firstContactor" 
							  value="#{certHome.instance.serviceSupplier.firstContactor}" />
					
					<p:outputLabel value="第一联系人电话" />				
					<h:outputText id="firstContactorPhoneNumber" 
							  value="#{certHome.instance.serviceSupplier.firstContactorPhoneNumber}" />
					
					<p:outputLabel value="第二联系人" />				
					<h:outputText id="secondContactor" 
							  value="#{certHome.instance.serviceSupplier.secondContactor}" />
					
					<p:outputLabel value="第二联系人电话" />				
					<h:outputText id="secondContactorPhoneNumber" 
							  value="#{certHome.instance.serviceSupplier.secondContactorPhoneNumber}" />
					
					<p:outputLabel value="员工数" />				
					<h:outputText id="employeeCount" 
							  value="#{certHome.instance.serviceSupplier.employeeCount}" />
					
					<p:outputLabel value="高级职称人数" />				
					<h:outputText id="highTitleEmployeeCount" 
							  value="#{certHome.instance.serviceSupplier.highTitleEmployeeCount}" />
					
					<p:outputLabel value="中级职称人数" />				
					<h:outputText id="mediumTitleEmployeeCount" 
							  value="#{certHome.instance.serviceSupplier.mediumTitleEmployeeCount}" />
					
					<p:outputLabel value="初级职称人数" />				
					<h:outputText id="beginnerTitleEmployeeCount" 
							  value="#{certHome.instance.serviceSupplier.beginnerTitleEmployeeCount}" />
						   
					<p:outputLabel value="是否政府服务供应商" />				
					<h:outputText id="govServiceSupplier" 
							   value="#{certHome.instance.serviceSupplier.govServiceSupplier ? '是' : '否'}" />
										   
					<p:outputLabel value="中介机构所在地区" />		
					<h:outputText id="region"
							   value="#{codeDicUtils.getCodeDicValueKeyMap('所在地区')[certHome.instance.serviceSupplier.region]}" />
					
					<p:outputLabel value="营业期限" />					
					<h:outputText id="businessAllotedTime"
							   value="#{certHome.instance.serviceSupplier.busnissAllotedTime}" 
							rendered="#{not certHome.instance.serviceSupplier.alwaysValid}">
						<f:convertDateTime pattern="yyyy-MM-dd"/>
					</h:outputText>	
					<h:outputText value="长期有效"
							   rendered="#{certHome.instance.serviceSupplier.alwaysValid}" />
					
					<p:outputLabel for="intro" value="机构简介" />	
					<h:outputText id="intro"
							   value="#{certHome.instance.serviceSupplier.intro}" />
				</h:panelGrid>
			</p:panel>
			<p:panel id="certs" header="资质证书" style="margin-bottom:10px;">
				<h:panelGrid columns="2" columnClasses="column1,column2" width="100%" cellpadding="5">
					<p:outputLabel for="cert"></p:outputLabel>
					<p:outputPanel id="cert">
						<c:forEach items="#{serviceSupplierHome.instance.allCertClasses}" var="_class">
							<p:panel header="#{_class.name}">
								<c:forEach items="#{serviceSupplierHome.instance.certGroupByClassMap[_class]}" var="_cert" varStatus="_status">
									<h:panelGrid header="资质证书#{_status.index + 1}" style="margin-bottom:10px;">
										<c:forEach items="#{_cert.qualificationTemplates}" var="_template">											
											<h:panelGrid columns="2" cellpadding="5"  columnClasses="column1,column2">	
												<p:outputLabel value="行业范围" />								
												<h:outputText 
													   value="#{_template.getSectorNames()}" />									
																								   
												<p:outputLabel value="等级" />
												<h:outputText 
													   value="#{_template.qualificationLevel.name}" />
											</h:panelGrid>
										</c:forEach>
									</h:panelGrid>
								</c:forEach>
							</p:panel>
						</c:forEach>
					</p:outputPanel>
					<ui:remove>
						<p:outputPanel  id="cert_remove" >
							<c:forEach items="#{certHome.instance.qualificationTemplates}" var="_template" varStatus="_status">
							<p:panel header="资质证书#{_status.index + 1}" style="margin-bottom:10px;">
								<h:panelGrid columns="2" cellpadding="5"  columnClasses="column1,column2">	
									<p:outputLabel for="qualificationClass#{_status.index + 1}" value="资质类别" />
									<h:outputText id="qualificationClass#{_status.index + 1}"
										   value="#{_template.qualificationClass.name}" />
									
									<p:outputLabel for="sector#{_status.index + 1}" value="行业范围" />								
									<h:outputText id="sector#{_status.index + 1}"
										   value="#{_template.getSectorNames()}" />									
									
										   
									<p:outputLabel for="level#{_status.index + 1}" value="等级" />
									<h:outputText id="level#{_status.index + 1}"
										   value="#{_template.qualificationLevel.name}" />
								</h:panelGrid>
							</p:panel>
						</c:forEach>		
						
						</p:outputPanel>
					</ui:remove>
					
					<p:outputLabel for="approveDate" value="批准时间" />
					<h:outputText id="approveDate" 
							   value="#{certHome.instance.approveDate}" >
						<f:convertDateTime  pattern="yyyy-MM-dd" />
					</h:outputText>
					
					<p:outputLabel for="approveLicenseNo" value="批准文号/资质证书号" />
					<h:outputText id="approveLicenseNo" 
							   value="#{certHome.instance.approveLicenseNo}" />
					
					<p:outputLabel for="contactor" value="联系人" />
					<h:outputText id="contactor" 
							   value="#{certHome.instance.contactor}" />
					
					<p:outputLabel for="contactorPhoneNumber" value="联系人电话" />
					<h:outputText id="contactorPhoneNumber"
					 		   value="#{certHome.instance.contactorPhoneNumber}" />
					
					<p:outputLabel for="allotedDate" value="有效日期" />
					<h:outputText id="allotedDate" 
							   value="#{certHome.instance.allotedDate}" >
						<f:convertDateTime pattern="yyyy-MM-dd"/>
					</h:outputText>
					
					<p:outputLabel for="approveDepartmentName" value="资质审核机关" />
					<h:outputText id="approveDepartmentName" 
							   value="#{certHome.instance.approveDepartmentName}" />
								
					<p:outputPanel for="certPhotos">						
						<p:outputLabel value="单位资质证书" /><br/>
						（扫描图片）
					</p:outputPanel>
					<p:outputPanel id="certPhotos">
						<div id="imgsPreview2" >
							<c:forEach items="#{certHome.instance.certPhotos}" var="_photo" varStatus="_status">
								<img  data-original="#{attachmentUtils.getFullPath(_photo)}" src="#{attachmentUtils.getFullPath(_photo)}"  width="240"/>
							</c:forEach>
						</div>	
						
					</p:outputPanel>
					
				</h:panelGrid>
			</p:panel>
			<p:commandButton action="#{certHome.audit()}" value="审核通过" ajax="false" />
			<p:commandButton oncomplete="PF('rejectDialog').show();" value="驳回" immediate="true"></p:commandButton>			
			<p:commandButton action="#{certHome.cancel()}" value="取消" immediate="true"></p:commandButton>			
		</h:form>
		
		<ui:remove>
			<p:dialog
				id="imageDialog"
				widgetVar="imageDialog"
				modal="true"
				width="60%"
			>
				<f:facet name="header">
					营业执照
				</f:facet>
				<h:form>
					<p:panel style="text-align: center;">
						<p:commandButton type="button" onclick="PF('switcher').previous();"
						    icon="ui-icon-circle-triangle-w" id="prev"/>
						<p:commandButton type="button" onclick="PF('switcher').next();"
						    icon="ui-icon-circle-triangle-e" id="next"/>
						<p:imageSwitch effect="wipe" widgetVar="switcher" id="manuelSwitcher"
		   					slideshowAuto="false">
							<p:repeat value="#{certHome.instance.certPhotos}" var="_photo" varStatus="_status">
								<p:graphicImage
									value="#{images.image}"
									style="max-width: 95%"
								>
									<f:param name="id" value="#{_photo.id}" />
								</p:graphicImage>
							</p:repeat>
						</p:imageSwitch>
					</p:panel>
				</h:form>
			</p:dialog>
		</ui:remove>
		
		<p:dialog id="rejectDialog" widgetVar="rejectDialog">
			<f:facet name="header">
				驳回原因
			</f:facet>
			<h:form>
				<p:panelGrid columns="2">
					<p:outputLabel for="reason" value="驳回原因"></p:outputLabel>
					<p:inputTextarea
						id="reason"
						value="#{rejectRecordHome.instance.reason}"
						required="true"
						cols="80"
						rows="5"
					></p:inputTextarea>
				</p:panelGrid>
				
				<p:commandButton action="#{certHome.reject()}" value="驳回" ajax="false" />
				<p:commandButton oncomplete="PF('rejectDialog').hide();" value="取消" immediate="true"></p:commandButton>
			</h:form>
		</p:dialog>
      
   	</ui:define>
</ui:composition>
